﻿using System;
using System.Xml.Linq;
using HigLabo.Net.Extensions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class Media : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public String DisplayUrl { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String ExpandedUrl { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int64 ID { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String IDString { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Indices Indices { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String MediaUrl { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String MediaUrlHttps { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Sizes Sizes { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int64 SourceStatusID { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String SourceStatusIDString { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String Type { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String Url { set; get; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public Media(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            var d = this.SetData(jsonText);

            this.DisplayUrl = d.ToString("display_url");
            this.ExpandedUrl = d.ToString("expanded_url");
            this.ID = d.ToInt64("id") ?? 0;
            this.IDString = d.ToString("id_str");
            this.Indices = new Indices(d.ToString("indices"));
            this.MediaUrl = d.ToString("media_url");
            this.MediaUrlHttps = d.ToString("media_url_https");
            this.Sizes = new Sizes(d.ToString("sizes"));
            this.SourceStatusID = d.ToInt64("source_status_id") ?? 0;
            this.SourceStatusIDString = d.ToString("source_status_id_str");
            this.Type = d.ToString("type");
            this.Url = d.ToString("url");
        }

        public override string ToString()
        {
            return this.Url;
        }
    }
}
